package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-06-13
 * Time: 21:45
 */

@Api(value = "课程教师接口", tags = "课程教师接口")
@RestController
public class CourseTeacherController {

    @Resource
    private CourseTeacherService courseTeacherService;


    @ApiOperation("查询课程教师")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> selectCourseTeacher(@PathVariable String courseId) {
        List<CourseTeacher> courseTeachers = courseTeacherService.getById(courseId);
        return courseTeachers;
    }

    @ApiOperation("添加课程教师")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody @Validated CourseTeacher courseTeacher) {
        CourseTeacher courseTeacher1 = courseTeacherService.saveCourseTeacher(courseTeacher);
        return courseTeacher1;
    }


    @ApiOperation("修改课程教师")
    @PutMapping("/courseTeacher")
    public CourseTeacher updteCourseTeacher(@RequestBody @Validated CourseTeacher courseTeacher) {
        CourseTeacher courseTeacher1 = courseTeacherService.saveCourseTeacher(courseTeacher);
        return courseTeacher1;
    }

    @ApiOperation("删除课程教师")
    @DeleteMapping("/courseTeacher/course/{courseId}/{teacherId}")
    public void addCourseTeacher(@PathVariable String courseId, @PathVariable String teacherId) {
        courseTeacherService.deleteCourseTeacher(courseId, teacherId);
    }



}
